//
//  HomeSureZhuangViewController.m
//  shuiyun
//
//  Created by 马田成 on 2017/9/15.
//  Copyright © 2017年 qianyi. All rights reserved.
//

#import "HomeSureZhuangViewController.h"

@interface HomeSureZhuangViewController ()<UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UITextField *dunNumTF;
@property (weak, nonatomic) IBOutlet UITextField *moneyTF;

@end

@implementation HomeSureZhuangViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setTitle:@"确认去装"];
    self.dunNumTF.keyboardType = UIKeyboardTypeNumberPad;
    self.dunNumTF.delegate = self;
    self.moneyTF.keyboardType =UIKeyboardTypeNumberPad;
    self.moneyTF.delegate = self;
    // Do any additional setup after loading the view from its nib.
}
//确认去装

- (IBAction)sureGoClick:(UIButton *)sender {
    
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:[[UIApplication sharedApplication]keyWindow] animated:YES];
    hud.tag = 500;
    //提示文本
    hud.labelText = @"正在加载...";
    //是否有遮罩
    hud.dimBackground = YES;
    NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
    
    NSString *token = [PublicFunction getConfigWithKey:@"token"];
    //    NSString *str = @"917b0ddccade4345b1b066fdc4971a14";
    NSString *userid = [PublicFunction getConfigWithKey:@"userid"];
    
    [productParams setValue:userid forKey:@"userid"];
    
    [productParams setValue:token forKey:@"token"];
    [productParams setValue:_huaJiaID forKey:@"id"];
    [productParams setValue:self.dunNumTF.text forKey:@"tonnage"];
    [productParams setValue:self.moneyTF.text forKey:@"money"];
    
    [[MNetworkHandler sharedInstance]conURL:hometGoodsToinstall networkType:NetWorkPOST params:productParams delegate:nil showHUD:NO successBlock:^(id returnData) {
        
        if ([[returnData objectForKey:@"code"]intValue]==1) {
            
            [PublicFunction showAlert:nil message:@"确认成功" duration:5.0f];
            
            [self.navigationController popViewControllerAnimated:YES];
            
            
       
            
            
            [hud removeFromSuperview];
        }
        
        else {
            
            [PublicFunction showAlert:nil message:[returnData objectForKey:@"msg"] duration:5.0f];
            [hud removeFromSuperview];
            
        }
        
    } failureBlock:^(NSError *error) {
        
        NSLog(@"%@",error);
        
        [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
        [hud removeFromSuperview];
    }];

    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
